import basic from './basic.js';
var actmodel = new basic();
 

actmodel.list = function (strtype) {
  if(!strtype)
  {
    strtype=""
  }
   
  var app = getApp();
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/api_huka',
      showLoading: false,      
      'data': { "op": "list",plugin:'smapi',strtype },
      'method': "post",
      success: function (res) {
     
                 
        resolve(res.data.data);
    
      },
      fail: function (res) {
        resolve({ status: -1, "message": "操作失败2" });
      },
      complete: function () {
      }
    },true);
  })
} 



actmodel.getmodel = function (id,strtype) {
  if(!strtype)
  {
    strtype=""
  }
   
  var app = getApp();
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/api_huka',
      showLoading: true,      
      'data': { "op": "getmodel",plugin:'smapi',strtype ,id},
      'method': "post",
      success: function (res) {
      
        resolve(res.data.data);
     
      },
      fail: function (res) {
        resolve({ status: -1, "message": "操作失败2" });
      },
      complete: function () {
      }
    },true);
  })
} 

actmodel.createorder = function (model) {
  var app = getApp();
  var data = { "op": "createorder",plugin:'smapi', model: model }
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/api_huka',
      'data': data,
      'method': "get",
      success: function (res) {
        if (res.data.errno == 0) {

          resolve(res.data.data);

        }
        reject(res.data.message);
      },
      fail: function (res) {

        reject(((res.data && res.data.message) ? res.data.message : res.errMsg));
      },
      complete: function () {
      }
    });
  });
}
actmodel.queryorder=function (id) {

  var app = getApp();
  var data = { "op": "queryorder", id: id,plugin:'smapi'}
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/api_huka',
      'data': data,
      'method': "post",
      success: function (res) {
        
        resolve(res.data.data);
      }
    })
})
}

actmodel.sendnotice=function (ordernum) {

  var app = getApp();
  var data = { "op": "sendnotice", ordernum: ordernum,plugin:'smapi'}
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/api_huka',
      'data': data,
      'method': "post",
      success: function (res) {
        
        resolve(res.data.data);
      }
    })
})
}
module.exports = actmodel;
